// 构造函数注入，engine作为参数注入
class Engine{
    start(){
        console.log('发动机启动')
    }
}
class Car{
    private engine:Engine;
    constructor(engine:Engine){
        this.engine = engine;
    }
    drive(){
        this.engine.start();
        console.log('开车')
    }
}
const engine = new Engine();
const car = new Car(engine);
car.drive();